<template>
  <div class="pagestyle">
    <list_controller ref="zujianname" v-model="state.optionsList" :options="state.optionsList" pageName=""
      @tabChange="tabChange" :tabName="state.tabNameData" :pId="route.query.primaryIndexId"
      :cid="route.query.childIndexId">
      <template v-slot:opraCurdBtn1="row">
        <span>
          <el-button type="primary" style="font-size:14px;" link size="small" @click="lookBtn(row.row.row)">查看
          </el-button>
          <el-button type="primary" style="font-size:14px;" link size="small" @click="editBtn(row.row.row)">编辑
          </el-button>
          <el-button type="primary" style="font-size:14px;" link size="small" @click="deleteBtn(row.row.row)">删除
          </el-button>
        </span>
      </template>
      <template v-slot:opraCurdBtnAll>
        <el-button class="btn" type="primary" link @click="addBtn('mul')">
          <el-icon>
            <CirclePlusFilled />
          </el-icon>
          <!-- <el-icon style="margin-right: 2px;">
            <svg-icon  icon-class="addtotal" />
          </el-icon> -->
          新增
        </el-button>
        <el-button class="btn" type="primary" link @click="deleteBtn('mul')">
          <el-icon>
            <DeleteFilled />
          </el-icon>删除
        </el-button>
      </template>
    </list_controller>
    <!-- 新增弹框模拟量 -->
    <teleport to="body">
      <vxe-modal esc-closable destroy-on-close :lock-view="false" :width="660" :height="auto" v-model="state.addModal"
        resize :mask="true">
        <template #title>
          <div class="w100 h100 fsc mask_title">{{state.modalTitle}}传感器</div>
        </template>
        <template #default>
          <div class="form_box">
            <el-form ref="formRef" :model="state.formData" :rules="state.rules" label-position="top">
              <div v-if="state.tabName =='simulate'">
                <p class="mask_sub_title">
                  <svg-icon class-name="search-icon" icon-class="dot" /><span>传感器信息</span></p>
                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item label="传感器名称" prop="sensorName">
                      <el-select :disabled="state.editDis" clearable filterable v-model="state.formData.sensorName"
                        placeholder="请选择" @change="sensorNameChange">
                        <el-option v-for="item in state.sensorNameList" :key="item.sensorName" :label="item.sensorName"
                          :value="item.sensorName">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="单位" prop="sensorUnit">
                      <el-input disabled v-model="state.formData.sensorUnit" placeholder="请输入">
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="主索引" prop="primaryIndexId">
                      <el-input disabled v-model="state.formData.primaryIndexId" placeholder="请输入">
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8" v-if="state.childIndexList !=null">
                    <el-form-item label="子索引" prop="childIndexId">
                      <el-select :disabled="state.editDis" clearable filterable v-model="state.formData.childIndexId"
                        placeholder="请选择" @change="childIndexChange">
                        <el-option v-for="item in state.childIndexList" :key="item.childIndexId"
                          :label="item.childIndexId+'-'+item.childIndexName" :value="item.childIndexId">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="低量程">
                      <div class="inputrange fbc">
                        <el-input disabled oninput="value=value.replace(/[^\d.]/g,'')" clearable
                          v-model.number="state.formData.lowScaleDown" placeholder="请输入">
                        </el-input>
                        <span>-</span>
                        <el-input disabled oninput="value=value.replace(/[^\d.]/g,'')" clearable
                          v-model.number="state.formData.lowScaleUp" placeholder="请输入">
                        </el-input>
                      </div>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="高量程">
                      <div class="inputrange fbc">
                        <el-input disabled oninput="value=value.replace(/[^\d.]/g,'')" clearable
                          v-model.number="state.formData.highScaleDown" placeholder="请输入">
                        </el-input>
                        <span>-</span>
                        <el-input disabled oninput="value=value.replace(/[^\d.]/g,'')" clearable
                          v-model.number="state.formData.highScaleUp" placeholder="请输入">
                        </el-input>
                      </div>
                    </el-form-item>
                  </el-col>

                  <el-col :span="8">
                    <el-form-item label="设备有效期">
                      <el-select clearable filterable v-model="state.formData.expiration" placeholder="请选择">
                        <el-option v-for="item in state.yearList" :key="item" :label="item" :value="item">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <p class="mask_sub_title">
                  <svg-icon class-name="search-icon" icon-class="dot" /><span>默认报警类型</span></p>
                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item label="报警模式" prop="alarmType">
                      <el-select clearable filterable v-model="state.formData.alarmType" placeholder="请选择"
                        @change="alarmTypeChange">
                        <el-option v-for="item in state.alarmmodeList" :key="item.code" :label="item.name"
                          :value="item.code">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8" v-if="state.formData.alarmType == 1 || state.formData.alarmType == 3">
                    <el-form-item label="上限报警值≥" prop="upAlarmValue">
                      <el-input :disabled="state.nowranDis" v-model="state.formData.upAlarmValue" placeholder="请输入">
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8" v-if="state.formData.alarmType == 1 || state.formData.alarmType == 3">
                    <el-form-item label="上限解报值＜" prop="upRelieveValue">
                      <el-input :disabled="state.nowranDis" v-model="state.formData.upRelieveValue" placeholder="请输入">
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8" v-if="state.formData.alarmType == 2 || state.formData.alarmType == 3">
                    <el-form-item label="下限报警值≥" prop="downAlarmValue">
                      <el-input :disabled="state.noshangwranDis" v-model="state.formData.downAlarmValue"
                        placeholder="请输入"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8" v-if="state.formData.alarmType == 2 || state.formData.alarmType == 3">
                    <el-form-item label="下限解报值＜" prop="downRelieveValue">
                      <el-input :disabled="state.noshangwranDis" v-model="state.formData.downRelieveValue"
                        placeholder="请输入"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <p class="mask_sub_title">
                  <svg-icon class-name="search-icon" icon-class="dot" /><span>其他</span></p>
                <el-row :gutter="20">
                  <el-col :span="16">
                    <el-form-item label="上传图片" prop="imagePath">
                      <el-upload action v-model:file-list="state.fileList" list-type="picture"
                        :before-upload="beforeUpload" :http-request="uploadHttpRequestAdd" ref="upload"
                        :on-preview="handlePictureCardPreview">
                        <el-button>
                          <el-icon>
                            <UploadFilled />
                          </el-icon>上传图片
                        </el-button>
                        <template #tip>
                          <div class="el-upload__tip">
                            上传图片支持jpg/png等，大小不超过 500kb
                          </div>
                        </template>
                      </el-upload>
                    </el-form-item>
                  </el-col>
                </el-row>
              </div>
              <div v-if="state.tabName =='switch'">
                <p class="mask_sub_title">
                  <svg-icon class-name="search-icon" icon-class="dot" /><span>传感器信息</span></p>
                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item label="名称" prop="sensorName">
                      <el-select :disabled="state.editDis" clearable filterable v-model="state.formData.sensorName"
                        placeholder="请输入/请选择" @change="sensorNameChange">
                        <el-option v-for="item in state.sensorNameList" :key="item.sensorName" :label="item.sensorName"
                          :value="item.sensorName">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="主索引" prop="primaryIndexId">
                      <el-input disabled v-model="state.formData.primaryIndexId" placeholder="请输入">
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="开关量模式" prop="switchModel">
                      <el-select disabled clearable filterable v-model="state.formData.switchModel" placeholder="请选择">
                        <el-option v-for="item in state.switchModelList" :key="item.code" :label="item.name"
                          :value="item.code">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8" v-if="state.childIndexList !=null">
                    <el-form-item label="子索引" prop="childIndexId">
                      <el-select :disabled="state.editDis" clearable filterable v-model="state.formData.childIndexId"
                        placeholder="请选择" @change="childIndexChange">
                        <el-option v-for="item in state.childIndexList" :key="item.childIndexId"
                          :label="item.childIndex" :value="item.childIndexId">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="高电平显示" prop="highShow">
                      <el-input disabled clearable v-model="state.formData.highShow" placeholder="请输入"
                        @blur="highShowBlur">
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="低电平显示" prop="lowShow">
                      <el-input disabled clearable v-model="state.formData.lowShow" placeholder="请输入"
                        @blur="lowShowBlur">
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="常态逻辑" prop="normalLogic">
                      <el-select disabled clearable filterable v-model="state.formData.normalLogic" placeholder="请选择">
                        <el-option v-for="item in state.normalLogicList" :key="item.code" :label="item.name"
                          :value="item.code">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="设备有效期">
                      <el-select clearable filterable v-model="state.formData.expiration" placeholder="请选择">
                        <el-option v-for="item in state.yearList" :key="item" :label="item" :value="item">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="报警类型" prop="alarmType">
                      <el-select clearable filterable v-model="state.formData.alarmType" placeholder="请选择">
                        <el-option v-for="item in state.alarmmodeswitchList" :key="item.code" :label="item.name+'报警'"
                          :value="item.code">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="20">
                  <el-col :span="16">
                    <el-form-item label="上传图片" prop="imagePath">
                      <el-upload action v-model:file-list="state.fileList1" list-type="picture"
                        :before-upload="beforeUpload1" :http-request="uploadHttpRequestAdd1" ref="upload1"
                        :on-preview="handlePictureCardPreview">
                        <el-button>
                          <el-icon>
                            <UploadFilled />
                          </el-icon>上传图片
                        </el-button>
                        <template #tip>
                          <div class="el-upload__tip">
                            上传图片支持jpg/png等，大小不超过 500kb
                          </div>
                        </template>
                      </el-upload>
                    </el-form-item>
                  </el-col>
                </el-row>
              </div>
              <div v-if="state.tabName =='add'">
                <p class="mask_sub_title">
                  <svg-icon class-name="search-icon" icon-class="dot" /><span>传感器信息</span></p>
                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item label="名称" prop="sensorName">
                      <el-select :disabled="state.editDis" clearable filterable v-model="state.formData.sensorName"
                        placeholder="请选择" @change="sensorNameChange">
                        <el-option v-for="item in state.sensorNameList" :key="item.sensorName" :label="item.sensorName"
                          :value="item.sensorName">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="单位" prop="sensorUnit">
                      <el-input disabled v-model="state.formData.sensorUnit" placeholder="请输入">
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="主索引" prop="primaryIndexId">
                      <el-input disabled v-model="state.formData.primaryIndexId" placeholder="请输入">
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="累计周期" prop="resetType">
                      <el-select disabled clearable v-model="state.formData.resetType" placeholder="请选择">
                        <el-option v-for="item in state.resetTypeList" :key="item.code" :label="item.name"
                          :value="item.code">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8" v-if="state.childIndexList != null">
                    <el-form-item label="子索引" prop="childIndexId">
                      <el-select :disabled="state.editDis" clearable filterable v-model="state.formData.childIndexId"
                        placeholder="请选择" @change="childIndexChange">
                        <el-option v-for="item in state.childIndexList" :key="item.childIndexId"
                          :label="item.childIndex" :value="item.childIndexId">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="设备有效期">
                      <el-select clearable filterable v-model="state.formData.expiration" placeholder="请选择">
                        <el-option v-for="item in state.yearList" :key="item" :label="item" :value="item">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <p class="mask_sub_title">
                  <svg-icon class-name="search-icon" icon-class="dot" /><span>累计参数</span></p>
                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item label="累计模式" prop="orderType">
                      <el-select disabled clearable v-model="state.formData.orderType" placeholder="请选择">
                        <el-option v-for="item in state.orderTypeList" :key="item.code" :label="item.name"
                          :value="item.code">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="起始值" prop="startValue">
                      <el-input disabled clearable v-model="state.formData.startValue" placeholder="请输入"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="变化值" prop="changeValue">
                      <el-input disabled clearable v-model="state.formData.changeValue" placeholder="请输入"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="上限值" prop="upLimitValue">
                      <el-input disabled clearable v-model="state.formData.upLimitValue" placeholder="请输入"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="16">
                    <el-form-item label="上传图片" prop="imagePath">
                      <el-upload action v-model:file-list="state.fileList2" list-type="picture"
                        :before-upload="beforeUpload2" :http-request="uploadHttpRequestAdd2" ref="upload2"
                        :on-preview="handlePictureCardPreview">
                        <el-button>
                          <el-icon>
                            <UploadFilled />
                          </el-icon>上传图片
                        </el-button>
                        <template #tip>
                          <div class="el-upload__tip">
                            上传图片支持jpg/png等，大小不超过 500kb
                          </div>
                        </template>
                      </el-upload>
                    </el-form-item>
                  </el-col>
                </el-row>
              </div>
              <div v-if="state.tabName =='multiple'">
                <p class="mask_sub_title">
                  <svg-icon class-name="search-icon" icon-class="dot" /><span>传感器信息</span></p>
                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item label="名称" prop="sensorName">
                      <el-input clearable v-model="state.formData.sensorName" @change="multiplename" placeholder="请输入">
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="设备有效期">
                      <el-select clearable filterable v-model="state.formData.expiration" placeholder="请选择">
                        <el-option v-for="item in state.yearList" :key="item" :label="item" :value="item">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <p class="mask_sub_title">
                  <svg-icon class-name="search-icon" icon-class="dot" /><span>多参数信息</span></p>
                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-tree-select v-model="state.nodeclickId" ref="treeRef" :data="state.getpointsensorList"
                      node-key="value" clearable placeholder="请选择" highlight-current @node-click="nodeclick" />
                  </el-col>
                  <el-col :span="1">
                    <el-button type="primary" @click="nodeclickchange">选择</el-button>
                  </el-col>
                  <el-col :span="24" style="margin-top:10px;">
                    <vxe-table height="240" :data="state.formData.sensorList" border="inner">
                      <vxe-column title="传感器名称" field="sensorName">
                      </vxe-column>
                      <vxe-column title="单位" field="sensorUnit">
                      </vxe-column>
                      <vxe-column title="主索引" field="primaryIndexId">
                      </vxe-column>
                      <vxe-column title="子索引" field="childIndex">
                      </vxe-column>
                      <vxe-column title="操作" field="show">
                        <template #default="{row,rowIndex}">
                          <el-button link type="primary" @click="sensorListdelClick(rowIndex)">
                            删除
                          </el-button>
                        </template>
                      </vxe-column>
                    </vxe-table>
                  </el-col>
                </el-row>
                <p class="mask_sub_title">
                  <svg-icon class-name="search-icon" icon-class="dot" /><span>其他</span></p>
                <el-row :gutter="20">
                  <el-col :span="16">
                    <el-form-item label="上传图片" prop="imagePath">
                      <el-upload action v-model:file-list="state.fileList3" list-type="picture"
                        :before-upload="beforeUpload3" :http-request="uploadHttpRequestAdd3" ref="upload2"
                        :on-preview="handlePictureCardPreview">
                        <el-button>
                          <el-icon>
                            <UploadFilled />
                          </el-icon>上传图片
                        </el-button>
                        <template #tip>
                          <div class="el-upload__tip">
                            上传图片支持jpg/png等，大小不超过 500kb
                          </div>
                        </template>
                      </el-upload>
                    </el-form-item>
                  </el-col>
                </el-row>
              </div>
            </el-form>
            <div class="form_footer">
              <el-button @click="cancel">取消</el-button>
              <el-button type="primary" @click="submitForm">
                确定
              </el-button>
            </div>
          </div>
        </template>
      </vxe-modal>
    </teleport>
    <!-- 详情 -->
    <el-drawer v-model="state.drawerShow" direction="rtl" size="50%" close-on-click-modal :modal="true">
      <template #header="{ close, titleId, titleClass }">
        <h4 class="mask_sub_title" style="color:#3E464F;margin:0;">
          <svg-icon class-name="search-icon" icon-class="dot" /><span>{{state.drawerTitle}}传感器详情</span></h4>
      </template>
      <div>
        <el-row :gutter="20"
          style="background: rgba(91, 109, 128, 0.04);display: flex;align-items: center;padding: 20px 0;">
          <el-col :span="8" style="text-align: center;">
            <div class="img_box">
              <img v-if="state.formData.imagePath !=null" :src="state.formData.imagePath" alt="" />
              <img v-else src="@/assets/images/noimg.png" />
            </div>
            <!-- <p>{{state.formData.sensorName}}</p> -->
          </el-col>
          <el-col :span="16">
            <el-row :gutter="20">
              <el-col :span="24">
                <div v-if="state.tabName =='simulate'">
                  <el-row :gutter="20">
                    <el-col :span="8">
                      <p>传感器名称</p>
                      <p>{{state.formData.sensorName}}</p>
                    </el-col>
                    <el-col :span="8">
                      <p>单位</p>
                      <p>{{state.formData.sensorUnit}}</p>
                    </el-col>
                    <el-col :span="8">
                      <p>主索引</p>
                      <p>{{state.formData.primaryIndexId}}</p>
                    </el-col>
                    <el-col :span="8">
                      <p>子索引</p>
                      <p>{{state.formData.childIndex}}</p>
                    </el-col>
                    <el-col :span="8">
                      <p>【高】量程上/下限</p>
                      <p v-if="state.formData.highScaleDown">
                        {{state.formData.highScaleDown}}/{{state.formData.highScaleUp}}</p>
                      <p v-else>- / -</p>
                    </el-col>
                    <el-col :span="8">
                      <p>报警模式</p>
                      <p>{{state.formData.alarmTypeName}}</p>
                    </el-col>
                    <el-col :span="8">
                      <p>上限报警/解报值</p>
                      <p v-if="state.formData.upAlarmValue">
                        {{state.formData.upAlarmValue}}/{{state.formData.upRelieveValue}}</p>
                      <p v-else>- / -</p>
                    </el-col>
                    <el-col :span="8">
                      <p>下限报警/解报值</p>
                      <p v-if="state.formData.downAlarmValue">
                        {{state.formData.downAlarmValue}}/{{state.formData.downRelieveValue}}</p>
                      <p v-else>- / -</p>
                    </el-col>
                    <el-col :span="8">
                      <p>设备有效期</p>
                      <p>{{state.formData.expiration}}</p>
                    </el-col>
                  </el-row>
                </div>
                <div v-if="state.tabName =='switch'">
                  <el-row :gutter="20">
                    <el-col :span="8">
                      <p>名称</p>
                      <p>{{state.formData.sensorName}}</p>
                    </el-col>
                    <el-col :span="8">
                      <p>主索引</p>
                      <p>{{state.formData.primaryIndexId}}</p>
                    </el-col>
                    <el-col :span="8">
                      <p>开关量模式</p>
                      <p>{{state.formData.switchModelName}}</p>
                    </el-col>
                    <el-col :span="8">
                      <p>子索引</p>
                      <p>{{state.formData.childIndex}}</p>
                    </el-col>
                    <el-col :span="8">
                      <p>高电平显示</p>
                      <p>{{state.formData.highShow}}</p>
                    </el-col>
                    <el-col :span="8">
                      <p>低电平显示</p>
                      <p>{{state.formData.lowShow}}</p>
                    </el-col>
                    <el-col :span="8">
                      <p>常态逻辑</p>
                      <p>{{state.formData.normalLogicName}}</p>
                    </el-col>
                    <el-col :span="8">
                      <p>设备有效期</p>
                      <p>{{state.formData.expiration}}</p>
                    </el-col>
                    <el-col :span="8">
                      <p>报警类型</p>
                      <p>{{state.formData.alarmTypeName}}</p>
                    </el-col>
                  </el-row>
                </div>
                <div v-if="state.tabName =='add'">
                  <el-row :gutter="20">
                    <el-col :span="8">
                      <p>名称</p>
                      <p>{{state.formData.sensorName}}</p>
                    </el-col>
                    <el-col :span="8">
                      <p>子索引</p>
                      <p>{{state.formData.childIndex}}</p>
                    </el-col>
                    <el-col :span="8">
                      <p>累计周期</p>
                      <p>{{state.formData.resetTypeName}}</p>
                    </el-col>
                    <el-col :span="8">
                      <p>累计模式</p>
                      <p>{{state.formData.orderTypeName}}</p>
                    </el-col>
                    <el-col :span="8">
                      <p>单位</p>
                      <p>{{state.formData.sensorUnit}}</p>
                    </el-col>
                    <el-col :span="8">
                      <p>起始值</p>
                      <p>{{state.formData.startValue}}</p>
                    </el-col>
                    <el-col :span="8">
                      <p>变化值</p>
                      <p>{{state.formData.changeValue}}</p>
                    </el-col>
                    <el-col :span="8">
                      <p>上限值</p>
                      <p>{{state.formData.upLimitValue}}</p>
                    </el-col>
                  </el-row>
                </div>
                <div v-if="state.tabName =='multiple'">
                  <el-row :gutter="20">
                    <el-col :span="8">
                      <p>名称</p>
                      <p>{{state.formData.sensorName}}</p>
                    </el-col>
                    <el-col :span="8">
                      <p>设备有效期</p>
                      <p>{{state.formData.expiration}}</p>
                    </el-col>
                  </el-row>
                </div>
              </el-col>
            </el-row>
          </el-col>
          <el-col :span="24" style="margin-top:10px;" v-if="state.tabName == 'multiple'">
            <vxe-table height="240" :data="state.formData.sensorList" border="inner">
              <vxe-column title="传感器名称" field="sensorName">
              </vxe-column>
              <vxe-column title="单位" field="sensorUnit">
              </vxe-column>
              <vxe-column title="主索引" field="primaryIndexId">
              </vxe-column>
              <vxe-column title="子索引" field="childIndex">
              </vxe-column>
            </vxe-table>
          </el-col>
        </el-row>
        <p class="drawer_sub_title" style="margin:20px 0 12px 0;">
          <span class="sub_title_line">引用测点</span>
        </p>
        <el-row :gutter="20"
          style="background: rgba(91, 109, 128, 0.04);display: flex;align-items: center;padding: 10px 0;margin-top:10px">
          <el-col :span="24">

            <div class="fsc" style="margin-bottom:10px;">
              <span class="wn" style="font-size:14px;font-weight:700;color:rgb(51, 51, 51);margin-right:10px;">编号</span>
              <el-input style="width:200px;margin-right:10px;" v-model="state.pointId" placeholder="请输入" clearable>
              </el-input>
              <el-button @click="btnclick(1)" size="default" type="primary">查询</el-button>
              <el-button @click="btnclick(2)" size="default" style="background-color:#f2f4f5;border:none;">重置
              </el-button>
            </div>
            <vxe-table height="240" :data="state.pontList">
              <vxe-column title="序号" type="seq" :width="55"></vxe-column>
              <vxe-column v-for="(item,index) in state.ponittableheads" :field="item.field" :title="item.title"
                :params="{name:item.name}" :width="item.width?item.width:''" :key="index"></vxe-column>
              <vxe-column title="操作">
                <template #default="{row}">
                  <el-button link type="primary" @click="tobtnClick(row)">查看测点详情</el-button>
                </template>
              </vxe-column>
            </vxe-table>
          </el-col>
        </el-row>
      </div>
      <template #footer>
        <div style="flex: auto">
          <el-button @click="cancelClick">取消</el-button>
          <el-button type="primary" @click="confirmClick(state.formData)">编辑</el-button>
        </div>
      </template>
    </el-drawer>
    <el-dialog v-model="state.dialogVisiblepictureCardPreview">
      <img  :src="state.dialogImageUrl" alt="Preview Image" />
    </el-dialog>
  </div>
</template>
<script setup>
  import list_controller from "@/components/commonCom/list_controller";
  import {
    computed,
    reactive,
    ref
  } from "vue";
  import {
    ElMessage,
    ElMessageBox
  } from 'element-plus'
  import {
    table_headers
  } from '@/components/commonCom/table_headers';
  import axios from "@/utils/request"
  import {
    getchildIndex,
    getsensorName,
    getunit,
    fileupload,
    getchildIndexadd,
    getsensorNameadd,
    getpointsensor,
    validParamData
  } from '@/api/config'
  import usePagesStore from '@/store/modules/pages'
  import {
    create
  } from "lodash";
  const {
    proxy
  } = getCurrentInstance();
  const store = usePagesStore()
  const router = useRouter();
  const route = useRoute();
  const upload = ref()
  const upload1 = ref()
  const upload2 = ref()
  components: {
    list_controller
  }
  let previewHttps =
    import.meta.env.VITE_APP_HTTP
  const optionsList = ref({})
  let state = reactive({
    num: 0,
    editDis: false,
    nowranDis: false,
    noshangwranDis: false,
    tabNameData: '模拟量传感器',
    optionsList: {},
    options: {
      tabList: [{
          tabIndex: 1,
          name: '模拟量传感器'
        }, {
          tabIndex: 2,
          name: '开关量传感器'
        }, {
          tabIndex: 3,
          name: '累计量传感器'
        },
        {
          tabIndex: 4,
          name: '多参传感器'
        }
      ],
      tableheads: computed(() => table_headers.sensorSimulate),
      queryList: {
        dropdownUrl: '',
        querys: [{
          field: 'sensorName',
          title: '传感器名称',
          type: 'input',
          binddata: ''
        }],
        queryMap: new Map([
          ['sensorTypeId', 'safety_pointType'],
          ['deviceTypeId', 'safety_deviceType'],
          ['alarmTypeId', 'alarmType']
        ])
      },
      dataUrl: '/sensor/simulate/list',
      delUrl: '/sensor/simulate/delete',
      addUrl: '/sensor/simulate/add',
      descUrl: '/sensor/simulate/detail?id=',
      editUrl: '/sensor/simulate/edit',
    },
    options1: {
      tabList: [{
          tabIndex: 1,
          name: '模拟量传感器'
        }, {
          tabIndex: 2,
          name: '开关量传感器'
        }, {
          tabIndex: 3,
          name: '累计量传感器'
        },
        {
          tabIndex: 4,
          name: '多参传感器'
        }
      ],
      tableheads: computed(() => table_headers.sensorSwitch),
      queryList: {
        dropdownUrl: '',
        querys: [{
          field: 'sensorName',
          title: '传感器名称',
          type: 'input',
          binddata: ''
        }],
        queryMap: new Map([
          ['sensorTypeId', 'safety_pointType'],
          ['deviceTypeId', 'safety_deviceType'],
          ['alarmTypeId', 'alarmType']
        ])
      },
      dataUrl: '/sensor/switch/list',
      delUrl: '/sensor/switch/delete',
      addUrl: '/sensor/switch/add',
      descUrl: '/sensor/switch/detail?id=',
      editUrl: '/sensor/switch/edit',
    },
    options2: {
      tabList: [{
          tabIndex: 1,
          name: '模拟量传感器'
        }, {
          tabIndex: 2,
          name: '开关量传感器'
        }, {
          tabIndex: 3,
          name: '累计量传感器'
        },
        {
          tabIndex: 4,
          name: '多参传感器'
        }
      ],
      tableheads: computed(() => table_headers.sensorAdd),
      queryList: {
        dropdownUrl: '',
        querys: [{
          field: 'sensorName',
          title: '传感器名称',
          type: 'input',
          binddata: ''
        }],
        queryMap: new Map([
          ['sensorTypeId', 'safety_pointType'],
          ['deviceTypeId', 'safety_deviceType'],
          ['alarmTypeId', 'alarmType']
        ])
      },
      dataUrl: '/sensor/add/list',
      delUrl: '/sensor/add/delete',
      addUrl: '/sensor/add/add',
      descUrl: '/sensor/add/detail?id=',
      editUrl: '/sensor/add/edit',
    },
    options3: {
      tabList: [{
          tabIndex: 1,
          name: '模拟量传感器'
        }, {
          tabIndex: 2,
          name: '开关量传感器'
        }, {
          tabIndex: 3,
          name: '累计量传感器'
        },
        {
          tabIndex: 4,
          name: '多参传感器'
        }
      ],
      tableheads: computed(() => table_headers.sensorMultiple),
      queryList: {
        dropdownUrl: '',
        querys: [{
          field: 'sensorName',
          title: '传感器名称',
          type: 'input',
          binddata: ''
        }],
        queryMap: new Map([
          ['sensorTypeId', 'safety_pointType'],
          ['deviceTypeId', 'safety_deviceType'],
          ['alarmTypeId', 'alarmType']
        ])
      },
      dataUrl: '/sensor/multiple/list',
      delUrl: '/sensor/multiple/delete',
      addUrl: '/sensor/multiple/add',
      descUrl: '/sensor/multiple/detail?id=',
      editUrl: '/sensor/multiple/edit',
    },
    // 表单
    tabName: 'simulate',
    addModal: false,
    drawerShow: false,
    drawerTitle: '模拟量',
    modalTitle: '新增模拟传感器',
    formRef: null,
    formData: {
      sensorName: ''
    },
    rules: {
      sensorName: [{
        required: true,
        message: '请输入传感器名称',
        trigger: 'blur'
      }],
      sensorUnit: [{
        required: true,
        message: '请选择单位',
        trigger: 'change'
      }],
      childIndexId: [{
        required: true,
        message: '请选择子索引',
        trigger: 'change'
      }],
      switchModel: [{
        required: true,
        message: '请选择开关量模式',
        trigger: 'change'
      }],
      normalLogic: [{
        required: true,
        message: '请选择常态逻辑',
        trigger: 'change'
      }],
      highShow: [{
        required: true,
        message: '请输入高电平名称',
        trigger: 'blur'
      }],
      lowShow: [{
        required: true,
        message: '请输入低电平名称',
        trigger: 'blur'
      }],
      alarmType: [{
        required: true,
        message: '请选择报警类型',
        trigger: 'change'
      }],
      resetType: [{
        required: true,
        message: '请选择累计周期',
        trigger: 'change'
      }],
      orderType: [{
        required: true,
        message: '请选择累计模式',
        trigger: 'change'
      }],
      sensorUnit: [{
        required: true,
        message: '请选择单位',
        trigger: 'change'
      }],
      startValue: [{
        required: true,
        message: '请输入起始值',
        trigger: 'blur'
      }],
      changeValue: [{
        required: true,
        message: '请输入变化值',
        trigger: 'blur'
      }],
      upLimitValue: [{
        required: true,
        message: '请输入上限值',
        trigger: 'blur'
      }],
    },
    editId: undefined,
    // 下拉数据
    childIndexList: null, //索引
    sensorNameList: [], //传感器
    unitList: [], //单位
    alarmmodeList: [{
      code: 0,
      name: '无报警'
    }, {
      code: 1,
      name: '上限报警'
    }, {
      code: 2,
      name: '下限报警'
    }, {
      code: 3,
      name: '上下限报警'
    }], //报警模式-模拟量
    alarmmodeswitchList: [{
      code: 0,
      name: '无'
    }, {
      code: 1,
      name: '高电平'
    }, {
      code: 2,
      name: '低电平'
    }], //报警模式-开关量
    normalLogicList: [{
        code: 0,
        name: '低电平'
      },
      {
        code: 1,
        name: '高电平'
      }
    ],
    switchModelList: [{
        code: 0,
        name: '二态'
      },
      {
        code: 1,
        name: '三态'
      }
    ],
    resetTypeList: [{
        code: 0,
        name: '个数'
      },
      {
        code: 1,
        name: '小时'
      }, {
        code: 2,
        name: '班'
      }, {
        code: 3,
        name: '天'
      }, {
        code: 4,
        name: '月'
      }, {
        code: 5,
        name: '年'
      }
    ],
    orderTypeList: [{
        code: 0,
        name: '递增'
      },
      {
        code: 1,
        name: '递减'
      }
    ],
    yearList: ['1年', '2年', '3年', '4年', '5年', '6年', '7年', '8年', '9年', '10年'],
    detailBtn: true,
    pontList: [],
    ponittableheads: computed(() => table_headers.sensorRefPoint),
    pointId: '',
    pointsensorId: '',
    nodeclickList: undefined,
    getpointsensorList: [],
    nodeclickId: undefined,
    childIndexId: undefined,
    normalLogic: undefined,
    fileList: [],
    fileList1: [],
    fileList2: [],
    fileList3: [],
    dialogVisiblepictureCardPreview: false,
    dialogImageUrl: ''
  })
  // 查看按钮
  function lookBtn(row) {
    console.log(row, 'rowrow');
    state.drawerShow = true
    state.detailBtn = false
    let descUrltype = state.options.descUrl
    if (state.tabName == 'simulate') {
      descUrltype = state.options.descUrl
      state.drawerTitle = '模拟量'
      state.pointsensorId = 'A' + row.id
      getpointList(row.pointId, 'A' + row.id)
    } else if (state.tabName == 'switch') {
      descUrltype = state.options1.descUrl
      state.drawerTitle = '开关量'
      state.pointsensorId = 'D' + row.id
      getpointList(row.pointId, 'D' + row.id)
    } else if (state.tabName == 'add') {
      state.drawerTitle = '累计量'
      descUrltype = state.options2.descUrl
      state.pointsensorId = 'S' + row.id
      getpointList(row.pointId, 'S' + row.id)
    } else {
      state.drawerTitle = '多参量'
      descUrltype = state.options3.descUrl
      state.pointsensorId = 'S' + row.id
      getpointList(row.pointId, row.id)
    }
    axios.get(descUrltype + row.id).then(res => {
      if (res.code == 200) {
        state.formData = res.data
      }
    })
  }
  // 引用测点查询
  function btnclick(type) {
    if (type == 1) {
      getpointList(state.pointId, state.pointsensorId)
    } else {
      state.pointId = ''
    }
  }

  function tobtnClick(row) {
    router.push({
      path: '/cspz/netConfig/net_pointConfig',
      query: {
        pointId: row.pointId
      }
    })
  }
  // 引用测点查询
  function getpointList(pointId, sensorId) {
    let data = {
      pointId: pointId,
      sensorId: sensorId
    }
    axios.post('/point/list', data).then(res => {
      state.pontList = res.data.list
    })
  }
  // 新增按钮
  function addBtn(row) {
    state.addModal = true
    state.formData = {}
    state.editId = undefined
    state.editDis = false
    state.childIndexList = null
    state.fileList = []
    state.fileList1 = []
    state.fileList2 = []
    state.fileList3 = []
    if (state.tabName == 'simulate') {
      state.modalTitle = '新增模拟量'
      getSelectList(state.tabName)

    } else if (state.tabName == 'switch') {
      state.modalTitle = '新增开关量'
      getSelectList(state.tabName)

    } else if (state.tabName == 'add') {
      state.modalTitle = '新增累计量'
      getSelectList(state.tabName)

    } else {
      state.modalTitle = '新增多参量'
      getgetpointsensorData()
    }
  }

  function LastStr(str) {
    if(str){
      let index = str.lastIndexOf("\/");
      str = str.substring(index + 1, str.length);
      return str;
    }
  }
  // 编辑按钮
  function editBtn(row) {
    state.addModal = true
    state.detailBtn = true
    state.editDis = true
    state.childIndexList = []
    let descUrltype = state.options.descUrl
    if (state.tabName == 'simulate') {
      descUrltype = state.options.descUrl
      state.modalTitle = '编辑模拟量'
    } else if (state.tabName == 'switch') {
      descUrltype = state.options1.descUrl
      state.modalTitle = '编辑开关量'
    } else if (state.tabName == 'add') {
      descUrltype = state.options2.descUrl
      state.modalTitle = '编辑累计量'
    } else {
      descUrltype = state.options3.descUrl
      state.modalTitle = '编辑多参量'
      state.nodeclickId = undefined
      getgetpointsensorData()
    }
    state.childIndexId = row.childIndexId
    state.normalLogic = row.normalLogic
    axios.get(descUrltype + row.id).then(res => {
      if (res.code == 200) {
        state.formData = res.data
        state.fileList = [{
          name: LastStr(state.formData.imagePath),
          url: state.formData.imagePath
        }]
        state.fileList1 = [{
          name: LastStr(state.formData.imagePath),
          url: state.formData.imagePath
        }]
        state.fileList2 = [{
          name: LastStr(state.formData.imagePath),
          url: state.formData.imagePath
        }]
        state.fileList3 = [{
          name: LastStr(state.formData.imagePath),
          url: state.formData.imagePath
        }]
        state.formData.childIndexId = res.data.childIndex
        state.editId = res.data.id
        state.editDis = true
        if (state.tabName == 'switch') {
          state.alarmmodeswitchList = [{
            code: 0,
            name: '无'
          }, {
            code: 1,
            name: state.formData.highShow
          }, {
            code: 2,
            name: state.formData.lowShow
          }]
        }
      }
    })
  }

  function deleteBtn(row) {
    let delUrltype = state.options.delUrl
    if (state.tabName == 'simulate') {
      delUrltype = state.options.delUrl
    } else if (state.tabName == 'switch') {
      delUrltype = state.options1.delUrl
    } else if (state.tabName == 'add') {
      delUrltype = state.options2.delUrl
    } else {
      delUrltype = state.options3.delUrl
    }
    let ids = []
    if (row != 'mul') {
      ids = [row.id]
    } else {
      if (store.records.length > 0) {
        ids = store.records.map(item => {
          return item.id
        })
      } else {
        proxy.$modal.msgSuccess('请先勾选所要删除数据!');
      }
    }
    if (ids.length > 0) {
      ElMessageBox.confirm(
          '确定要删除吗?',
          '温馨提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
          }
        )
        .then(() => {
          axios.post(delUrltype, ids).then(res => {
            if (res.code == 200) {
              proxy.$refs['zujianname'].getData()
              state.addModal = false
              proxy.$modal.msgSuccess(res.msg);
              store.records = []
            }
          })
        })
        .catch(() => {
          proxy.$modal.msgWarning('删除取消');
        })

    }

  }
  // 取消抽屉
  function cancelClick() {
    state.drawerShow = false
  }
  // 编辑抽屉
  function confirmClick(row) {
    // state.drawerShow = false
    state.addModal = true
    state.detailBtn = true
    state.editDis = true
    state.childIndexList = []
    let descUrltype = state.options.descUrl
    if (state.tabName == 'simulate') {
      descUrltype = state.options.descUrl
      state.modalTitle = '编辑模拟量'
    } else if (state.tabName == 'switch') {
      descUrltype = state.options1.descUrl
      state.modalTitle = '编辑开关量'
      // state.alarmmodeswitchList = [{
      //   code: 0,
      //   name: '无'
      // }, {
      //   code: 1,
      //   name: '开'
      // }, {
      //   code: 2,
      //   name: '停'
      // }]
    } else if (state.tabName == 'add') {
      descUrltype = state.options2.descUrl
      state.modalTitle = '编辑累计量'
    } else {
      descUrltype = state.options3.descUrl
      state.modalTitle = '编辑多参量'
      state.nodeclickId = undefined
      getgetpointsensorData()
    }
    state.childIndexId = row.childIndexId
    axios.get(descUrltype + row.id).then(res => {
      if (res.code == 200) {
        state.formData = res.data
        state.formData.childIndexId = res.data.childIndex
        state.editId = res.data.id
        state.editDis = true
        if (state.tabName == 'switch') {
          state.alarmmodeswitchList = [{
            code: 0,
            name: '无'
          }, {
            code: 1,
            name: state.formData.highShow
          }, {
            code: 2,
            name: state.formData.lowShow
          }]
        }
      }
    })

  }
  /** 提交按钮 */
  function submitForm() {
    let addUrltype = state.options.addUrl
    let editUrltype = state.options.editUrl
    if (state.tabName == 'simulate') {
      addUrltype = state.options.addUrl
      editUrltype = state.options.editUrl
    } else if (state.tabName == 'switch') {
      addUrltype = state.options1.addUrl
      editUrltype = state.options1.editUrl
    } else if (state.tabName == 'add') {
      addUrltype = state.options2.addUrl
      editUrltype = state.options2.editUrl
    } else {
      addUrltype = state.options3.addUrl
      editUrltype = state.options3.editUrl
    }
    proxy.$refs["formRef"].validate(valid => {
      if (valid) {
        console.log(state.childIndexId, 'state.childIndexId');
        state.formData.childIndexId = state.childIndexId
        state.formData.normalLogic = state.normalLogic
        if (state.editId) {
          state.formData.id = state.editId
          axios.post(editUrltype, state.formData).then(res => {
            if (res.code == 200) {
              proxy.$refs['zujianname'].getData()
              state.addModal = false
              proxy.$modal.msgSuccess(res.msg);
            }
          })
        } else {
          axios.post(addUrltype, state.formData).then(res => {
            if (res.code == 200) {
              proxy.$refs['zujianname'].getData()
              state.addModal = false
              proxy.$modal.msgSuccess(res.msg);
            }
          })
        }
      }
    })
  }

  function cancel() {
    state.addModal = false
  }

  function multiplename(val) {
    axios.get('/sensor/multiple/validParam', {
      params: {
        type: 0,
        value: val,
        id: state.editId
      }
    }).then(res => {
      if (res.code == 200) {

      }
    })
  }
  state.optionsList = state.options

  function tabChange(val) {
    state.formData = {}
    state.tabNameData = val
    if (val == ('模拟量传感器')) {
      state.optionsList = state.options
      setTimeout(() => {
        proxy.$refs['zujianname'].getData()
      }, 200);
      getSelectList('simulate')
      state.tabName = 'simulate'
      state.formData.alarmType = state.alarmmodeList[0].code
    } else if (val == '开关量传感器') {
      state.optionsList = state.options1
      setTimeout(() => {
        proxy.$refs['zujianname'].getData()
      }, 200);
      getSelectList('switch')
      state.tabName = 'switch'
      state.formData.alarmType = state.alarmmodeswitchList[0].code
    } else if (val == '累计量传感器') {
      state.optionsList = state.options2
      setTimeout(() => {
        proxy.$refs['zujianname'].getData()
      }, 200);
      getSelectList('add')
      state.tabName = 'add'
    } else if (val == '多参传感器') {
      state.optionsList = state.options3
      state.tabName = 'multiple'
      setTimeout(() => {
        proxy.$refs['zujianname'].getData()
      }, 200);
    }
  }
  // 获取多参新增下拉
  function getgetpointsensorData() {
    let arr = []
    getpointsensor().then(res => {
      if (res.data.length > 0) {
        res.data.forEach(item => {
          item.label = item.name
          item.value = item.name
          item.sensors.forEach(item1 => {
            item1.label = item1.sensorName
            item1.value = item1.primaryIndexId
            let child = item1.childIndexList.map(item2 => {
              item2.label = item2.childIndex
              item2.value = item2.childIndex
              return item2
            })
            item1.children = child
          })
          item.children = item.sensors
        })
        arr = res.data
        state.getpointsensorList = arr
      }

    })
  }

  function getSelectList(val) {
    getsensorName(val).then(res => {
      state.sensorNameList = res.data
    })
  }

  getSelectList('simulate')
  //传感器名称下拉事件
  function sensorNameChange(val) {
    state.sensorNameList.forEach(item => {
      if (item.sensorName == val) {
        state.formData.sensorUnit = item.sensorUnit
        state.formData.primaryIndexId = item.primaryIndexId
        if (state.tabName == 'simulate') {
          state.childIndexList = item.sensorSimulateChildList
          if (item.sensorSimulateChildList == null) {
            state.formData.highScaleDown = item.highScaleDown
            state.formData.highScaleUp = item.highScaleUp
            state.formData.lowScaleDown = item.lowScaleDown
            state.formData.lowScaleUp = item.lowScaleUp
          } else {
            state.formData.highScaleDown = undefined
            state.formData.highScaleUp = undefined
            state.formData.lowScaleDown = undefined
            state.formData.lowScaleUp = undefined
          }
        } else if (state.tabName == 'switch') {
          state.childIndexList = item.sensorSwitchChildList
          if (item.sensorSwitchChildList == null) {
            state.formData.switchModel = item.switchModel
            state.formData.highShow = item.highShow
            state.formData.lowShow = item.lowShow
            state.normalLogic = item.normalLogic
            state.formData.normalLogic = item.normalLogicName
            // state.alarmmodeswitchList=[{code:0,name:'无'},{code:1,name:'开'},{code:2,name:'停'}]
            state.alarmmodeswitchList = [{
              code: 0,
              name: '无'
            }, {
              code: 1,
              name: item.highShow
            }, {
              code: 2,
              name: item.lowShow
            }]
          } else {
            state.formData.highShow = undefined
            state.formData.lowShow = undefined
            state.formData.normalLogic = undefined
          }
        } else if (state.tabName == 'add') {
          state.childIndexList = item.sensorAddChildList
          state.formData.resetType = item.resetType
          if (item.sensorAddChildList == null) {
            state.formData.orderType = item.orderType
            state.formData.startValue = item.startValue
            state.formData.changeValue = item.changeValue
            state.formData.upLimitValue = item.upLimitValue
            state.formData.upLimitValue = item.upLimitValue
          } else {}
        }
      }
    })
  }
  //传感器子索引下拉事件
  function childIndexChange(val) {
    state.childIndexList.forEach(item => {
      if (item.childIndexId == val) {
        state.formData.childIndexName = item.childIndexName
        state.formData.highScaleDown = item.highScaleDown
        state.formData.highScaleUp = item.highScaleUp
        state.formData.lowScaleDown = item.lowScaleDown
        state.formData.lowScaleUp = item.lowScaleUp
        state.formData.sensorUnit=item.sensorUnit
        // 开关量
        state.formData.switchModel = item.switchModel
        state.formData.highShow = item.highShow
        state.formData.lowShow = item.lowShow
        state.formData.normalLogic = item.normalLogicName
        state.alarmmodeswitchList = [{
          code: 0,
          name: '无'
        }, {
          code: 1,
          name: item.highShow
        }, {
          code: 2,
          name: item.lowShow
        }]
        // state.alarmmodeswitchList=[{code:0,name:'无'},{code:1,name:'开'},{code:2,name:'停'}]
        // 累计量
        state.formData.orderType = item.orderType
        state.formData.startValue = item.startValue
        state.formData.changeValue = item.changeValue
        state.formData.upLimitValue = item.upLimitValue
        state.formData.upLimitValue = item.upLimitValue
      }
    })
  }
  const fileType = [
    "jpg", "png", "gif", "jpg", "jpeg"
  ] // 允许的文件类型
  const uploadHttpRequestAdd = (data) => {
    upload.value.clearFiles();
    const formData = new FormData();
    formData.append("file", data.file);
    fileupload(formData).then(res => {
      state.formData.imagePath = previewHttps + res.fileName
      state.fileList.push({
        name: res.originalFilename,
        url: state.formData.imagePath
      })
      proxy.$modal.msgSuccess(res.msg);
    })
  }
  const beforeUpload = (file) => { //上传前的钩子
    if (file.type != "" || file.type != null || file.type != undefined) {
      //截取文件的后缀，判断文件类型
      const FileExt = file.name.replace(/.+\./, "").toLowerCase();
      // 计算文件的大小
      const isLt5M = file.size / 1024 < 500; //这里做文件大小限制
      //如果大于500kb
      if (!isLt5M) {
        proxy.$modal.msgWarning("上传文件大小超过限制!" + file.size);
        upLoading.value = 0
        return false;
      }
      //如果文件类型不在允许上传的范围内
      if (fileType.includes(FileExt)) {
        return true;
      } else {
        proxy.$modal.msgWarning("上传文件格式不正确!");
        upLoading.value = 0
        return false;
      }
    }
  }
  const uploadHttpRequestAdd1 = (data) => {
    upload1.value.clearFiles();
    const formData = new FormData();
    formData.append("file", data.file);
    fileupload(formData).then(res => {
      state.formData.imagePath = previewHttps + res.fileName
      state.fileList1.push({
        name: res.originalFilename,
        url: state.formData.imagePath
      })
      proxy.$modal.msgSuccess(res.msg);
    })
  }
  const beforeUpload1 = (file) => { //上传前的钩子
    if (file.type != "" || file.type != null || file.type != undefined) {
      //截取文件的后缀，判断文件类型
      const FileExt = file.name.replace(/.+\./, "").toLowerCase();
      // 计算文件的大小
      const isLt5M = file.size / 1024 < 500; //这里做文件大小限制
      //如果大于500kb
      if (!isLt5M) {
        proxy.$modal.msgWarning("上传文件大小超过限制!");
        upLoading.value = 0
        return false;
      }
      //如果文件类型不在允许上传的范围内
      if (fileType.includes(FileExt)) {
        return true;
      } else {
        proxy.$modal.msgWarning("上传文件格式不正确!");
        upLoading.value = 0
        return false;
      }
    }
  }
  const uploadHttpRequestAdd2 = (data) => {
    upload2.value.clearFiles();
    const formData = new FormData();
    formData.append("file", data.file);
    fileupload(formData).then(res => {
      state.formData.imagePath = previewHttps + res.fileName
      state.fileList2.push({
        name: res.originalFilename,
        url: state.formData.imagePath
      })
      proxy.$modal.msgSuccess(res.msg);
    })
  }
  const beforeUpload2 = (file) => { //上传前的钩子
    if (file.type != "" || file.type != null || file.type != undefined) {
      //截取文件的后缀，判断文件类型
      const FileExt = file.name.replace(/.+\./, "").toLowerCase();
      // 计算文件的大小
      const isLt5M = file.size / 1024 < 500; //这里做文件大小限制
      //如果大于500kb
      if (!isLt5M) {
        proxy.$modal.msgWarning("上传文件大小超过限制!");
        upLoading.value = 0
        return false;
      }
      //如果文件类型不在允许上传的范围内
      if (fileType.includes(FileExt)) {
        return true;
      } else {
        proxy.$modal.msgWarning("上传文件格式不正确!");
        upLoading.value = 0
        return false;
      }
    }
  }
  const uploadHttpRequestAdd3 = (data) => {
    upload2.value.clearFiles();
    const formData = new FormData();
    formData.append("file", data.file);
    fileupload(formData).then(res => {
      state.formData.imagePath = previewHttps + res.fileName
      state.fileList3.push({
        name: res.originalFilename,
        url: state.formData.imagePath
      })
      proxy.$modal.msgSuccess(res.msg);
    })
  }
  const beforeUpload3 = (file) => { //上传前的钩子
    if (file.type != "" || file.type != null || file.type != undefined) {
      //截取文件的后缀，判断文件类型
      const FileExt = file.name.replace(/.+\./, "").toLowerCase();
      // 计算文件的大小
      const isLt5M = file.size / 1024 < 500; //这里做文件大小限制
      //如果大于500kb
      if (!isLt5M) {
        proxy.$modal.msgWarning("上传文件大小超过限制!");
        upLoading.value = 0
        return false;
      }
      //如果文件类型不在允许上传的范围内
      if (fileType.includes(FileExt)) {
        return true;
      } else {
        proxy.$modal.msgWarning("上传文件格式不正确!");
        upLoading.value = 0
        return false;
      }
    }
  }

  function handlePictureCardPreview(uploadFile) {
    state.dialogVisiblepictureCardPreview = true
    state.dialogImageUrl = uploadFile.url
  }

  function alarmTypeChange(val) {
    if (val == 0) {
      state.nowranDis = true
      state.noshangwranDis = true
    } else if (val == 1) {
      state.nowranDis = false
      state.noshangwranDis = true
    } else {
      state.nowranDis = false
      state.noshangwranDis = false
    }
  }
  // 高电平输入事件
  function highShowBlur(val) {
    state.normalLogicList[1].name = state.formData.highShow
  }

  function lowShowBlur(val) {
    state.normalLogicList[0].name = state.formData.lowShow
  }
  // 多参信息树形
  function nodeclick(data, node) {
    state.nodeclickList = data
    // delete state.nodeclickList.label
    // delete state.nodeclickList.value
  }

  function nodeclickchange() {
    if (!state.formData.sensorList) {
      state.formData.sensorList = []
    }
    state.formData.sensorList.push(state.nodeclickList)
    state.formData.sensorList = Array.from(new Set(state.formData.sensorList))
    state.formData.sensorIdList = state.formData.sensorList.map(item => {
      return item.sensorId
    })
  }

  function sensorListdelClick(row) {
    state.formData.sensorList.splice(row, 1);
    state.formData.sensorIdList = state.formData.sensorList.map(item => {
      return item.sensorId
    })
  }

  console.log(route.query);

  if (route.query.primaryIndexId) {
    if (route.query.tabName == 'simulate') {
      state.tabNameData = '模拟量传感器'
      state.tabName = 'simulate'
      state.optionsList = state.options
    }
    if (route.query.tabName == 'switch') {
      state.tabNameData = '开关量传感器'
      state.tabName = 'switch'
      state.optionsList = state.options1
    }
    if (route.query.tabName == 'add') {
      state.tabNameData = '累计量传感器'
      state.tabName = 'add'
      state.optionsList = state.options2
    }
    if (route.query.tabName == 'multiple') {
      state.tabNameData = '多参传感器'
      state.tabName = 'multiple'
      state.optionsList = state.options3
    }
  }
</script>
<style scoped lang="scss">
  .inputrange {
    background: rgba(91, 109, 128, 0.08);

    ::v-deep .el-input__wrapper {
      box-shadow: none;
      background: rgba(91, 109, 128, 0.0);
    }
  }
</style>